<?php
if (!defined('BASEPATH'))
    exit('No direct script access allowed');

function generate_captcha($length = '6', $expiration = '900', $width = '300', $height = '100', $path = './generated_contents/captcha/')
{
    $ci = &get_instance();
    
    $ci->load->helper('string');
    $ci->load->helper('captcha');
            
    $captcha                    = array();
    $captcha['word']            = strtoupper( random_string('alnum', $length) );
    $captcha['img_path']        = FCPATH . $path;
    $captcha['img_url']         = base_url() . $path;
    $captcha['font_path']       = FCPATH . '/fonts/calibri-webfont.ttf';
    $captcha['img_width']       = $width;
    $captcha['img_height']      = $height;
    $captcha['expiration']      = $expiration; // 15 minutes

    $captcha_img = create_captcha($captcha);

    // save captcha to session as flash data
    $ci->session->set_flashdata('captcha', $captcha_img);

    return $captcha_img;
}

/* End of file generator_helper.php */
/* Location: ./application/helpers/generator_helper.php */